﻿using System.Collections.Generic;
using System.Threading;

namespace PhiStore.Threading
{
    /// <summary>
    /// Class with static functions for starting up threads
    /// </summary>
    public class Booster
    {
        /// <summary>
        /// Starts a thread
        /// </summary>
        /// <param name="thread">The Boostable thread to start</param>
        public static void Boost(Boostable thread)
        {
            new Thread(new ThreadStart(thread.Run)).Start();
        }

        /// <summary>
        /// Starts numerous threads, one at a time
        /// </summary>
        /// <param name="threads">The Boostable threads to start</param>
        public static void Boost(IEnumerable<Boostable> threads)
        {
            foreach (Boostable thread in threads)
            {
                Boost(thread);
            }
        }

        //public static void Boost(IList<Boostable> threads)
        //{
        //    foreach (Boostable thread in threads)
        //    {
        //        Boost(thread);
        //    }
        //}

    }

    /// <summary>
    /// Interface for threads using the ThreadBooster
    /// </summary>
    public interface Boostable
    {
        /// <summary>
        /// Method use as ThreadStart
        /// </summary>
        void Run();
    }
}
